/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.controllers;
 

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
 
@Controller
public class DefaultController {
 
    /* PODSTAWOWA NAWIGACJA */
    @RequestMapping(value={"/","/index"}, method= RequestMethod.GET)
    public String index(ModelMap map) {

        return "index";
    }
    @RequestMapping(value="/about", method= RequestMethod.GET)
    public String about(ModelMap map) {
        
        return "about";
    }
    @RequestMapping(value="/offer", method= RequestMethod.GET)
    public String offer(ModelMap map) {
        
        return "offer";
    }
    @RequestMapping(value="/prices", method= RequestMethod.GET)
    public String prices(ModelMap map) {
        
        return "prices";
    }
    @RequestMapping(value="/gallery", method= RequestMethod.GET)
    public String gallery(ModelMap map) {
        
        return "gallery";
    }
    @RequestMapping(value="/contact", method= RequestMethod.GET)
    public String contact(ModelMap map) {
        
        return "contact";
    }
    @RequestMapping(value="/new-account", method= RequestMethod.GET)
    public String newAccount(ModelMap map) {

        return "new-account";
    }
    /* LOGOWANIE */
    @RequestMapping(value = "/login", method = RequestMethod.GET)
	public ModelAndView login(@RequestParam(value = "error", required = false) String error,
			@RequestParam(value = "logout", required = false) String logout) {

		ModelAndView model = new ModelAndView();
		if (error != null) {
			model.addObject("error", "Niepoprawne dane!");
		}

		if (logout != null) {
			model.addObject("msg", "Zostałeś wylogowany.");
		}
		model.setViewName("login");

		return model;

	}
    /* STRONA BŁĘDU 404 */
    @RequestMapping(value="/**", method= RequestMethod.GET)
    public String error(ModelMap map) {

        return "errorPage";
    }
    
 
}